package samsung.yx;

import java.io.FileInputStream;
import java.util.Scanner;

public class Circle1223 {

	static int data[][], bool[];

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(new FileInputStream(
				"C:\\Users\\tstcit\\Desktop\\samsung_yx\\loop1223.txt"));
		int T = sc.nextInt();
		for (int testcase = 0; testcase < T; testcase++) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			data = new int[M][2];
			bool = new int[M];
			for (int i = 0; i < M; i++) {
				data[i][0] = sc.nextInt();
				data[i][1] = sc.nextInt();
				System.out.println(data[i][0] + " " + data[i][1]);
			}

		}
	}

	public static void dfs(int step) {

	}
}
